function a(a) {
    return a && a.__esModule ? a : {
        default: a
    };
}

a(require("../../utils/filter"));

var e = a(require("../../api/api")), t = a(require("../../utils/util")), i = require("../../config/constants");

getApp();

Page({
    data: {
        pageNum: 1,
        pageSize: 40,
        hasMore: !0,
        content_list: []
    },
    onLoad: function() {
        this.fetchMessageList();
    },
    fetchMessageList: function(a) {
        var t = this, i = this, s = {
            page: i.data.pageNum,
            page_size: 40,
            nickname: a || ""
        };
        e.default.messageList({
            data: s,
            success: function(a) {
                var e = i.data.content_list;
                if (a && a.data) {
                    1 == i.data.pageNum && (e = []);
                    var s = a.data.data;
                    s.forEach(i.mergeMessageInfo), s.length < i.data.pageSize ? t.setData({
                        content_list: e.concat(s),
                        hasMore: !1
                    }) : t.setData({
                        content_list: e.concat(s),
                        hasMore: !0,
                        pageNum: i.data.pageNum + 1
                    });
                }
            }
        });
    },
    mergeMessageInfo: function(a) {
        a.avatar_file_name_url = i.CDN_ADDR + a.oppo_user_obj.avatar_file_name + "_Avatar.jpg", 
        a.date_time_ago = t.default.dateTimeAgo(a.create_time);
    },
    onReachBottom: function(a) {
        var e = this;
        e.data.hasMore && e.fetchMessageList();
    },
    searchValueInput: function(a) {
        var e = a.detail.value;
        this.setData({
            searchValue: e
        }), this.data.pageNum = 1, this.fetchMessageList(e);
    },
    bindToChatDetail: function(a) {
        var e = a.currentTarget.id;
        wx.navigateTo({
            url: "chat/chat?user_id=" + e
        });
    },
    onImageError: function(a) {
        var e = this;
        t.default.errImgFun(a, e);
    }
});